package org.newlifecac;




import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TextView;

public class NewLifecac extends Activity
{
	private AlertDialog.Builder dialog;
	
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash);

		PackageManager pm = getPackageManager();
		try
		{
			PackageInfo pi = pm.getPackageInfo("org.newlifecac", 0);
			TextView versionNumber = (TextView) findViewById(R.id.versionNumber);
			versionNumber.setText("Version " + pi.versionName);
		} catch (Exception e)
		{
			e.printStackTrace();
		}

		new Handler().postDelayed(new Runnable()
		{

			public void run()
			{
				Intent intent = new Intent(NewLifecac.this,
						FilePickerActivity.class);
				startActivity(intent);
				NewLifecac.this.finish();
			}

		}, 2500);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.menu, menu);
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item)
	{

		int item_id = item.getItemId();
		switch (item_id)
		{
		case R.id.main:

			break;
		
		case R.id.notice:
			Intent intent = new Intent();
			intent.setClass(NewLifecac.this, GetHtml.class);
			NewLifecac.this.startActivityForResult(intent,CONTEXT_RESTRICTED);
			break;
		
		case R.id.about:
			Intent i = new Intent();
			i.setClass(NewLifecac.this, SMSSender.class);
			NewLifecac.this.startActivityForResult(i,CONTEXT_IGNORE_SECURITY);

			break;

		case R.id.exit:
			exit("Exit", "Do You Want To Exit?");
			break;

		}
		return true;
	}
	
	public void exit(String title, String message)
	{
		dialog = new AlertDialog.Builder(NewLifecac.this);
		dialog.setTitle(title).setIcon(android.R.drawable.ic_dialog_info)
				.setMessage(message)
				.setPositiveButton("Yes", new DialogInterface.OnClickListener()
				{
					public void onClick(DialogInterface dialog, int which)
					{
						finish();
					}
				})
				.setNegativeButton("No", new DialogInterface.OnClickListener()
				{
					public void onClick(DialogInterface dialog, int which)
					{
						dialog.cancel();
					}
				}).create().show();
	}
}
